/*
 * Copyright (c)  2008 Sebastien Tremblay
 *
 * id3-tag-builder - classes.db.MusicTrack.java
 *
 * All source and documentation is copyrighted by Sebastien Tremblay
 * (seb at ryders dot net) and made available under the Apache License 2.0.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * $Id: MusicTrack.java 33 2010-04-02 07:47:55Z ryders $
 */
package com.empireone.id3tagbuilder.classes.db;

import java.io.File;

/**
 *
 * @author Sebastien Tremblay
 */
public class MusicTrack {

    private int discNo;
    private int trackNo;
    private String artist;
    private int year;
    private String genre;
    private String title;
    private String comment;
    private File file;

    private MusicAlbum musicAlbum;

    /**
     *
     * @return the coverArt
     */
    public String getCoverArt() {
        return musicAlbum != null ? musicAlbum.getCoverArt() : null;
    }

    /**
     *
     * @return the coverArt
     */
    public int getDiscCount() {
        return musicAlbum != null ? musicAlbum.getDiscCount() : 0;
    }

    /**
     * @return the discNo
     */
    public int getDiscNo() {
        return discNo;
    }

    /**
     * @param discNo the discNo to set
     */
    public void setDiscNo(int discNo) {
        this.discNo = discNo;
    }

    /**
     * @return the trackNo
     */
    public int getTrackNo() {
        return trackNo;
    }

    /**
     * @param trackNo the trackNo to set
     */
    public void setTrackNo(int trackNo) {
        this.trackNo = trackNo;
    }

    /**
     * @return the artist
     */
    public String getArtist() {
        return artist != null ? artist : musicAlbum.getArtist();
    }

    /**
     * @param artist the artist to set
     */
    public void setArtist(String artist) {
        this.artist = artist;
    }

    /**
     * @return the year
     */
    public int getYear() {
        return year > 0 ? year : (musicAlbum != null ? musicAlbum.getYear() : 0);
    }

    /**
     * @param year the year to set
     */
    public void setYear(int year) {
        this.year = year;
    }

    /**
     * @return the genre
     */
    public String getGenre() {
        return genre != null ? genre : (musicAlbum != null ? musicAlbum.getGenre() : null);
    }

    /**
     * @param genre the genre to set
     */
    public void setGenre(String genre) {
        this.genre = genre;
    }

    /**
     * @return the title
     */
    public String getTitle() {
        return title;
    }

    /**
     * @param title the title to set
     */
    public void setTitle(String title) {
        this.title = title;
    }

    /**
     * @return the comment
     */
    public String getComment() {
        return comment;
    }

    /**
     * @param comment the comment to set
     */
    public void setComment(String comment) {
        this.comment = comment;
    }

    /**
     * @return the file
     */
    public File getFile() {
        return file;
    }

    /**
     * @return the album
     */
    public String getAlbum() {
        return musicAlbum != null ? musicAlbum.getName() : null;
    }

    /**
     * @param file the file to set
     */
    public void setFile(File file) {
        this.file = file;
    }

    /**
     * @param musicAlbum
     */
    public void setMusicAlbum(MusicAlbum musicAlbum) {
        this.musicAlbum = musicAlbum;
    }

    @Override
    public String toString() {
        String res = "";

        res = "\n  Track:" + trackNo;
        res = "\n  Disc:" + discNo;
        res = "\n  Title:" + title;
        res = "\n  Artist:" + artist;
        res = "\n  Year:" + year;
        res = "\n  ---------- ";

        return res;
    }
}
